<script type="text/javascript"><!--//--><![CDATA[//><!--
    console.clear();
    var grid_reload = function(){
        $('#datagrid').datagrid('reload', $('#fm_search').serializeObject());
    };

    $(document).ready(function() {
        // Setup Datagrid
        $('#datagrid').datagrid({  
            url:gs_path+'/'+controller+'/getdata', 
            queryParams: $('#fm_search').serializeObject(),
            height:340,
            pagination:true,
            fitColumns:true,
            columns:[[
                { field : 'ck', checkbox:true, width: 40, align: 'center' },
                // { field : 'id_satuan_pk', title : 'ID', width : 120, sortable:true },
                { field : 'id_barang_masuk_pk', title : 'ID Barang Masuk', width : 100, sortable:true },
                { field : 'id_po_fk', title : 'ID PO', width : 100, sortable:true },
                { field : 'tgl_barang_masuk', title : 'Tanggal Barang Masuk', width : 200, sortable:true},
                { field : 'ket_barang_masuk', title : 'Keterangan', width : 100, sortable:true },
            ]]
        });
        
        // Create Dialog
        $('#dialog_container').dialog({
            closed:true,
            modal:true,
            title: '_',
            width:600,
            buttons:[{
                text:'Save',
                iconCls:'icon-save',
                handler:function(){
                    $('#form_master').submitForm('/'+controller+'/ajax_post', { onComplete : function(){ $('#dialog_container').dialog('close'); $('#datagrid').datagrid('reload'); }} );
                }
            },{
                text:'Close',
                iconCls:'icon-cancel',
                handler:function(){
                    $('#dialog_container').dialog('close');
                }
            }]
        });
        
        
        // Set Action Button
        var buttons = [ { label: 'Add', icon: 'add', onclick: function() {
                            loadPage(gs_path + '/' + controller + '/create/');
                        } },
                        { label: 'Edit', icon: 'edit', onclick: function() {
                            var oSel = $('#datagrid').datagrid('getSelected');
                            if (oSel == null) {
                                $.messager.alert('&nbsp;', gs_msg_row_unselected, 'warning'); 
                            } else {
                                loadPage(gs_path + '/' + controller + '/edit/?id_barang_masuk_pk='+urlencode(oSel.id_barang_masuk_pk));
                            } 
                        } },
                        {label: 'Delete', icon: 'delete', onclick: function() { 
                            var oSel = $('#datagrid').datagrid('getSelected'); 
                            if (oSel == null) { 
                                $.messager.alert('&nbsp;', gs_msg_row_unselected, 'warning'); 
                            } else { 
                                deleteData(['id_barang_masuk_pk']);
                            } 
                        }}];
        setAction(buttons);
        
        
        $('#fm_search').focusFirst();
    });
//--><!]]></script>

<div id="tb" style="padding:5px;height:auto">
    <div>
        <form id="fm_search" onsubmit="grid_reload(); return false;">
            <table class="tb_form" style="margin-bottom:0px">
            <tr>
                <td width="100">Keyword</td>
                <td><input type="text" id="keyword" name="keyword" class="textfield medium" />
                    <a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="grid_reload(); return false;">Search</a>
                </td>
            </tr>
            </table>
        </form>
    </div>
</div>
<div id="datagrid" toolbar="#tb"></div>


